package com.chenqq.qsocket.fractory;

import android.util.Log;

import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.core.write.WriteRequest;
import org.apache.mina.filter.keepalive.KeepAliveFilter;
import org.apache.mina.filter.keepalive.KeepAliveMessageFactory;
import org.apache.mina.filter.keepalive.KeepAliveRequestTimeoutHandler;

public class HeartBeatKeepAliveFilter extends KeepAliveFilter {
    public HeartBeatKeepAliveFilter(KeepAliveMessageFactory messageFactory) {
        super(messageFactory);
    }

    public HeartBeatKeepAliveFilter(KeepAliveMessageFactory messageFactory, IdleStatus interestedIdleStatus) {
        super(messageFactory, interestedIdleStatus);
    }

    public HeartBeatKeepAliveFilter(KeepAliveMessageFactory messageFactory, KeepAliveRequestTimeoutHandler policy) {
        super(messageFactory, policy);
    }

    public HeartBeatKeepAliveFilter(KeepAliveMessageFactory messageFactory, IdleStatus interestedIdleStatus, KeepAliveRequestTimeoutHandler policy) {
        super(messageFactory, interestedIdleStatus, policy);
    }

    public HeartBeatKeepAliveFilter(KeepAliveMessageFactory messageFactory, IdleStatus interestedIdleStatus, KeepAliveRequestTimeoutHandler policy, int keepAliveRequestInterval, int keepAliveRequestTimeout) {
        super(messageFactory, interestedIdleStatus, policy, keepAliveRequestInterval, keepAliveRequestTimeout);
    }

    @Override
    public void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception {
        Log.e("当前状态",session.getRemoteAddress()+" ="+status.toString());
        super.sessionIdle(nextFilter, session, status);
    }

    @Override
    public void messageSent(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception {
        Log.e("messageSent",session.getRemoteAddress()+" ="+writeRequest.getMessage());
        super.messageSent(nextFilter, session, writeRequest);
    }

    @Override
    public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception {
        Log.e("messageReceived",session.getRemoteAddress()+" ="+message);
        super.messageReceived(nextFilter, session, message);
    }
}
